import java.io.*;
public class Main {
	public static void main(String[] args) throws Exception {	
	    BufferedReader stdin = 
	            new BufferedReader(
	                new InputStreamReader(System.in));
	    int ans;
	    char ch;
	    while( true ) {
	    	String line = stdin.readLine();
	    	if (line.charAt(0)=='#' && line.length()==1) break;
	    	ans = 0;
	    	for (int i=0; i<line.length(); ++i)
	    	{
	    		ch = line.charAt(i);
	    		if (ch>='A' && ch<='Z')
	    			ans += (i+1)*((int)(ch-'A')+1);
	    	}
	    	System.out.println(ans);		
	    }
	}
}

